<?php
    include ('_connect.php');

    $username = $_POST['uname'];
    $password = $_POST['pwd'];

    // $sql = "select * from gzxtable2 where username= '$username' and password = '$password'";
    $sql = "select * from gzxtable2 where username='$username' and password='$password'";
    // echo $sql;
    $result = $mysqli->query($sql);
    // $result = $mysqli->query($sql);
    // var_dump($result->num_rows); 
    if($result->num_rows>0){
        echo "<script src='cookie.js'></script>";//js添加cookie储存起来
        echo "<script> cookie.set('isLogin','true',); cookie.set('username','$username',2,);</script>";//储存cokie保存两天
        echo "<script>alert('登录成功'); location.href='../src/html/index.html';</script>";
    }else{
        echo "<script>alert('登录失败'); location.href='../src/html/index.html';</script>";
    }
?>